﻿#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int num(int a, int b)
{
    if (a >= b)
        return a - b;
    else
        return b - a;
}
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int arr1[100], arr2[100];
    int sum1 = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr1[i]);
        sum1 += arr1[i];
    }
    int min = sum1;
    for (int i = 0; i < m; i++)
    {
        scanf("%d", &arr2[i]);
    }
    int  k, l;
    for (int i = 0; i < m; i++)
    {
       int  sum2 = 0;
        for (int j = i; j < m; j++)
        {
            sum2 += arr2[j];
            if (num(sum1, sum2) < min)//插值比较，并优化差值
            {
                min = num(sum1, sum2);
                k = i;
                l = j;
            }
        }
    }
    for (int i = k; i <= l; i++)
    {
        printf("%d ", arr2[i]);
    }
    return 0;
}